/*
 * @Author: yanjikun
 * @Date: 2022-01-05 11:26:46
 * @LastEditors: yanjikun
 * @LastEditTime: 2022-05-07 11:27:51
 * @Description: file content
 */
import { RowProps } from 'ant-design-vue'
import { formProps } from 'ant-design-vue/es/form'
// import { formProps } from 'ant-design-vue/lib/form'
import { CSSProperties, ExtractPropTypes, PropType } from 'vue'
import BasicForm from '..'
import { FieldMapToTime, FormConfig } from './types/form'
import { formActionProps } from './types/formAction'

export const basicProps = {
  ...formProps(),
  ...formActionProps,
  config: {
    type: Array as PropType<FormConfig[]>,
    default: () => [],
  },
  initialValues: {
    type: Object as PropType<Recordable>,
  },
  labelWidth: {
    type: [Number, String] as PropType<number | string>,
    default: '100px',
  },
  baseRowStyle: {
    type: Object as PropType<CSSProperties>,
  },
  itemSize: {
    type: String as PropType<'default' | 'large' | 'small'>,
  },
  showAdvancedButton: {
    type: Boolean as PropType<boolean>,
  },
  autoAdvancedLine: {
    type: Number as PropType<number>,
    default: 3,
  },
  showActionButtonGroup: {
    type: Boolean as PropType<boolean>,
    default: true,
  },
  resetFunc: {
    type: Function as PropType<() => Promise<void>>,
  },
  submitFunc: {
    type: Function as PropType<() => Promise<void>>,
  },
  submitOnReset: { type: Boolean as PropType<boolean> },
  rowProps: {
    type: Object as PropType<RowProps>,
  },
  /** 转化时间 */
  transformDateFunc: {
    type: Function as PropType<Fn>,
    default: (date: any) => {
      return date?.format?.('YYYY-MM-DD HH:mm:ss') ?? date
    },
  },
  fieldMapToTime: {
    type: Array as PropType<FieldMapToTime>,
    default: () => [],
  },
}

export type BasicProps = Partial<ExtractPropTypes<typeof basicProps>>

export type BasicFormInstance = InstanceType<typeof BasicForm>
